package com.woniuxy.juc.reentrant;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.ReentrantLock;

/**
 * <P> @Author: ideaAdmin
 * <P> TODO: Class
 * <P> TODO: 可重入锁
 * <P> Date: 2022/4/8:8:48
 * <P> Description:
 */
@Slf4j(topic = "c.ReentrantLockTest1")
public class ReentrantLockTest1 {
    private static ReentrantLock lock = new ReentrantLock();
    public static void main(String[] args) {

        lock.lock();

        try {
            System.out.println("ReentrantLockTest1.main");
            m1();
        }finally {
            lock.unlock();
        }

    }

    public static void m1(){

        lock.lock();

        try {
            System.out.println("ReentrantLockTest1.m1");
            m2();
        }finally {
            lock.unlock();
        }
    }


    public static void m2(){

        lock.lock();

        try {
            System.out.println("ReentrantLockTest1.m2");
        }finally {
            lock.unlock();
        }
    }
}
